package com.lzp.androidprojects.simple1.presenter;


import com.lzp.androidprojects.simple1.view.MvpView;

import java.lang.ref.WeakReference;

/**
 * Created by Administrator on 2019/6/1.
 */
public class BasePresenter<V extends MvpView> {
    private WeakReference<V> weakReference;
    public void attach(V mvpView){
        weakReference = new WeakReference(mvpView);
    }

    public void deAttach(){
        if(weakReference!=null){
            weakReference.clear();
            weakReference=null;
        }
    }

    public MvpView getView(){
        return  weakReference.get();
    }
}
